package com.blt.car.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import blt.app_core.api.base.CoreManager;

/**
 * Created by xgp on 2017/6/13.
 */

public abstract class BaseFragment extends Fragment {
    private ViewHolder viewHolder;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        viewHolder = new ViewHolder(inflater, container, getLayoutId());
        CoreManager.addClient(this);
        return viewHolder.getmRootView();
    }

    protected abstract int getLayoutId();

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
        initView(viewHolder);
    }

    protected abstract void initView(ViewHolder holder);

    protected void initData() {

    }

    protected void toast(String text) {
        Toast.makeText(getContext(), text, Toast.LENGTH_SHORT).show();
    }
}
